package com.zijie;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;

public class Test5 {
	public static void main(String[] args)throws Exception {
		copy(new File("E:\\PR\\a.txt"), new File("E:\\untitled\\a.txt"));
	}
	public static void copy(InputStream in,OutputStream out)throws IOException {
		try {
			byte[] bs = new byte[1024];
			int len = 0;
			int i = 0;
			int size =0;
			int size1 = in.available();
			while((len = in.read(bs)) >-1) {
				System.out.format("%5d-%6d:%s\n",i++,len,Arrays.toString(bs));
				out.write(bs,0,len);
			}
			System.out.println("文件大小:"+size+"-"+size1);
		} finally {
			try {
			in.close();
		} catch (Exception e) {
			// TODO: handle exception
		}try {
			out.close();
		} catch (Exception e) {
			// TODO: handle exception
		}
		}
	}
	public static void copy(File srcFile,File targetFile)throws IOException {
		copy(new FileInputStream(srcFile), new FileOutputStream(targetFile));
	}
}
